import request from '@/utils/httpRequest'

// 品牌列表
export function getBrandConfigList(param) {
  const res =  request({
    url: `/pop/brand`,
    method: 'get',
    params: param || {}
  })
  return res
}

// 新增品牌
export function addBrand(param) {
  return request({
    url: `/pop/brand`,
    method: 'post',
    params: param || {}
  })
}

// 编辑品牌
export function editBrand(param) {
  return request({
    url: `/pop/brand`,
    method: 'put',
    params: param || {}
  })
}

//授权列表
export function getBrandAuthList(param) {
  return request({
    url: `/pop/brand_auth`,
    method: 'get',
    params: param || {}
  })
}

//未授权商家下拉列表
export function getShopList(param) {
  return request({
    url: `/pop/brand/select_shop`,
    method: 'get',
    params: param || {}
  })
}

//新增品牌授权
export function addBrandAuth(param) {
  return request({
    url: `/pop/brand_auth`,
    method: 'post',
    params: param || {}
  })
}

//解除品牌授权
export function cancelBrandAuth(param) {
  return request({
    url: `/pop/brand_auth`,
    method: 'delete',
    params: param || {}
  })
}

//颜色,规格列表
export function getSpecList(param) {
  return request({
    url: '/pop/spec',
    method: 'get',
    params: param || {}
  })
}

//新增颜色规格
export function addColorSpec(param) {
  return request({
    url: '/pop/spec',
    method: 'post',
    params: param || {}
  })
}

//编辑颜色规格
export function editColorSpec(param) {
  return request({
    url: '/pop/spec/'+param.id,
    method: 'put',
    params: param || {}
  })
}

//删除颜色规格
export function deleteColorSpec(param) {
  return request({
    url: '/pop/spec/'+param.id,
    method: 'delete',
    params: param || {}
  })
}

//规格配置
export function getConfigSpec(param) {
  return request({
    url: `/pop/spec/config`,
    method: 'get',
    params: param || {}
  })
}

export function selectAuthBrand(data = {}) {
  return request({
    url: '/pop/brand/select_auth',
    method: 'get',
    params: { ...data }
  })
}

//根据分类id获取关联规格属性组
export function getSpecGroup(data = {}) {
  return request({
    url: '/pop/spec/attr',
    method: 'get',
    params: { ...data }
  })
}

export function exportE3Spec(data = {}) {
  return request({
    url: '/pop/spec/export_to_e3',
    method: 'post',
    responseType: 'blob',
    data: { ...data }
  })
}

export function importSpecStatus(data = {}) {
  return request({
    url: '/pop/spec/import_e3_status',
    method: 'post',
    responseType: 'blob',
    data
  })
}